import { requestClient } from '#/api/request';
import type { PageResult } from '#/api/common';
import type { TableColumnVO, TableColumnForm, TableColumnQuery } from '#/api/demo/tableColumn/types';

/**
 * 查询数据字段列表
 * @param query
 * @returns {*}
 */

export const listTableColumn = (query?: TableColumnQuery) =>
  requestClient.get<PageResult<TableColumnVO>>('/data/tableColumn/list', { params: query });

/**
 * 查询数据字段详细
 * @param id
 */
export const getTableColumn = (id: string | number) =>
  requestClient.get<TableColumnVO>(`/data/tableColumn/${id}`);

/**
 * 新增数据字段
 * @param data
 */
export const addTableColumn = (data: TableColumnForm) =>
  requestClient.postWithMsg<void>('/data/tableColumn', data);

/**
 * 修改数据字段
 * @param data
 */
export const updateTableColumn = (data: TableColumnForm) =>
  requestClient.putWithMsg<void>('/data/tableColumn', data);

/**
 * 删除数据字段
 * @param id
 */
export const delTableColumn = (id: string | number | Array<string | number>) =>
  requestClient.deleteWithMsg<void>(`/data/tableColumn/${id}`);
